<?php

class Service_GaldicController extends Zend_Controller_Action
{

    public function init()
    {
        $layout = Zend_Layout::getMvcInstance();        
        $layout->disableLayout();
        
        $this->getHelper('viewRenderer')->setNoRender();
        
        $this->server = new Zend_Json_Server();
        $this->server->setClass('Service_Model_GalDic');        
    }

    public function indexAction()
    {
        $this->queryAction();
    }

    public function queryAction()
    {
        if ('GET' == $_SERVER['REQUEST_METHOD']) {
            $this->_discoverService();
        }
        
        $this->server->handle();
    }

    private function _discoverService()
    {
        // Indicate the URL endpoint, and the JSON-RPC version used:        
        $this->server->setTarget('/service/galdic')
               ->setEnvelope(Zend_Json_Server_Smd::ENV_JSONRPC_2);
        
        // Grab the SMD
        $smd = $this->server->getServiceMap();
        //$smd->setDojoCompatible(true);
        
        // Return the SMD to the client
        header('Content-Type: application/json');
        echo $smd;
        return;        
    }


}



